<template>
  <a-modal v-model="visibleEquipment" title="请选择设备" @ok="handleEquipmentOk" :width="800">
    <a-table
      bordered
      type="'radio'"
      rowKey="id"
      :row-selection="{ type:tableType, selectedRowKeys: selectedFileRowKeys, onChange: onSelectEquipmentChange }"
      :columns="columnsFile"
      :data-source="tableData"
    />
  </a-modal>
</template>

<script>
  import { getEquipmentInfoListNoPid } from '@/api/digitization'

  export default {
        name: "EquipmentMmodal.vue",
        data(){
          return {
            visibleEquipment: false,
            // selectedFileRowKeys:[],
            selectedFileList:[],
            columnsFile:[
              {
                title: '#',
                dataIndex: '',
                key:'rowIndex',
                width:60,
                align:"center",
                customRender:function (t,r,index) {
                  return parseInt(index)+1;
                }
              },
              {
                title:'供应商名称',
                align:"center",
                dataIndex: 'supplier_dictText',
              },
              {
                title:'设备编号',
                align:"center",
                dataIndex: 'eqpNo'
              },
              {
                title:'设备名称',
                align:"center",
                dataIndex: 'name'
              },
              {
                title:'类名',
                align:"center",
                dataIndex: 'typename'
              },
              /*{
                title:'创建人',
                align:"center",
                dataIndex: 'createBy'
              },
              {
                title:'创建日期',
                align:"center",
                dataIndex: 'createTime',
                customRender:function (text) {
                  return !text?"":(text.length>10?text.substr(0,10):text)
                }
              },*/
            ],
            // dataFile:[],
          }
        },
        props:{
          tableData:{
            type: Array,
            default(){
              return []
            }
          },
          tableType: {
            type: String,
            default(){
              return 'checkbox'
            }
          },
          selectedFileRowKeys:{
            type: Array,
            default(){
              return []
            }
          }
        },
        created(){

        },
        methods: {
          handleAddEquipment(){
            this.visibleEquipment = true;
          },
          handleEquipmentOk(){
            this.visibleEquipment = false;
            this.$emit('equipmentOk',{selectedFileRowKeys:this.selectedFileRowKeys,selectedFileList:this.selectedFileList})
          },
          onSelectEquipmentChange(selectedRowKeys,row){
            // this.selectedFileRowKeys = selectedRowKeys;
            this.selectedFileList = row;
            this.$emit('equipmentChange',{selectedFileRowKeys:selectedRowKeys,selectedFileList:row})

          },
        }
    }
</script>

<style scoped>

</style>